﻿using Hallenberg.SmartClient.Menu;
using NUnit.Framework;

namespace Hallenberg.SmartClient.Test
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestFixture]
    public class MenuManagerTest
    {
        private WorkItemController m_WorkItem;

        [Test]
        public void Initialize()
        {
            m_WorkItem = new WorkItemController();
        }

        [Test]
        public void SmartClient_MenuManager_AddSimpleMenus()
        {
            MenuItemContainer menuManager = m_WorkItem.MenuManagers.Create("MainMenu");

            MenuItem customersMenuItem = new MenuItem("Customers", "Customers", string.Empty);
            MenuItem ordersMenuItem = new MenuItem("Orders", "Orders", string.Empty);

            Assert.That(menuManager.AddMenuItem(customersMenuItem), Is.True);
            Assert.That(menuManager.AddMenuItem(ordersMenuItem), Is.True);
        }

        [Test]
        public void SmartClient_InsertMenuAfter()
        {
            MenuItemContainer menuManager = m_WorkItem.MenuManagers.Create("CustomerMenu");

            MenuItem indexMenuItem = new MenuItem("Index", "Index", string.Empty);
            MenuItem ordersMenuItem = new MenuItem("Orders", "Orders", string.Empty) { SortIndex = 100 };
            MenuItem productsMenuItem = new MenuItem("Products", "Products", string.Empty) { SortIndex = 200 };
            MenuItem aboutMenuItem = new MenuItem("About", "About", string.Empty) { SortIndex = 300 };

            menuManager.AddMenuItem(ordersMenuItem);
            menuManager.AddMenuItem(productsMenuItem);
            menuManager.AddMenuItem(indexMenuItem);
            menuManager.AddMenuItem(aboutMenuItem);

            Assert.That(menuManager.ChildItems[0].MenuItemName, Is.EqualTo("Index"));
            Assert.That(menuManager.ChildItems[1].MenuItemName, Is.EqualTo("Orders"));
            Assert.That(menuManager.ChildItems[2].MenuItemName, Is.EqualTo("Products"));
            Assert.That(menuManager.ChildItems[3].MenuItemName, Is.EqualTo("About"));
        }
    }
}
